/* $RCSFile: ADNDynListMember.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynListMember.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:33  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynListMember : DynEntity
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.listmember)
            {}

            public override Type DynType
            { get { return typeof(ADNDynListMember); } }

            public override string DynTypename
            {   get{ return CrmStr.listmember;}}

            public override DynEntity Build()
            {   return new ADNDynListMember();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynListMember(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynListMember(w);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynListMember(w,PrimaryKeyValue);}
        }

        static ADNDynListMember(){new Ftor();} 

        public override bool HasPrimaryField
        {
            get
            {
                return false;
            }
        }
        public override bool HasOwnerProperty
        {
            get
            {
                return false;
            }
        }

        public override bool HasBusinessUnitProperty
        {
            get
            {
                return false;
            }
        }

        public ADNDynListMember(): base()
		{}

        public ADNDynListMember(CRMWrapperBase w)
			: base(w,CrmStr.listmember)
		{}

		public ADNDynListMember(CRMWrapperBase w, Guid CrmId)
			: base(w,CrmStr.listmember, CrmId)
		{}

		public ADNDynListMember(CRMWrapperBase w, InternalDynamicEntity e)
			: base(w,CrmStr.listmember,e,null,null)
		{}

		public ADNDynListMember(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(w,CrmStr.listmember,e,prop,s)
		{}

        public ADNDynListMember(ResetWrapperHandler fn)
			: base(fn,CrmStr.listmember)
		{}

		public ADNDynListMember(ResetWrapperHandler fn, Guid CrmId)
			: base(fn,CrmStr.listmember, CrmId)
		{}

		public ADNDynListMember(ResetWrapperHandler fn, InternalDynamicEntity e)
			: base(fn,CrmStr.listmember,e,null,null)
		{}

		public ADNDynListMember(ResetWrapperHandler fn, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(fn,CrmStr.listmember,e,prop,s)
		{}
    
        /// <summary>
		/// Crm Key
		/// </summary>
        [CrmDynAttribute(CrmStr.listmember)]
        public Guid listmemberid
		{
			get
			{
				return KeyPropertyValue(CrmStr.listmemberid);
			}
			set
			{
				AddKeyProperty(CrmStr.listmemberid, value);
			}
		}

        protected override void SetCrmIdProperty(Guid crmId)
        {
           if ( !dicProperty.ContainsKey(CrmStr.listmemberid) || KeyPropertyValue(CrmStr.listmemberid) != listmemberid )
                listmemberid   =   crmId;
        }
        

        public override Guid PrimaryKeyGuidValue
        {
           get
           {
                return listmemberid;
           }
           set
           {
               listmemberid    =   value;
           }
        }

        string _DefaultEntityName   =   CrmStr.account;
		public string DefaultEntityName
		{
			get
			{
				return _DefaultEntityName;
			}
			set
			{
                switch (value)
                {
                    case CrmStr.account:
                    case CrmStr.contact:
                    case CrmStr.systemuser:
                    case CrmStr.lead:
                        _DefaultEntityName  =   value;
                        break;
                }
			}
		}
       
        [CrmDynAttribute(CrmStr.listmember)]
		public Guid listid
		{
            get
            {
                return LookupPropertyValue(CrmStr.listid);
            }
            set
            {
                AddLookupProperty(CrmStr.listid,CrmStr.list,value);
            }
        }


        public string listName
        {
            get
            {
                if (ContainsKey(CrmStr.listid))
                    return LookupPropertyName(CrmStr.listid);
                return string.Empty;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [CrmDynAttribute(CrmStr.listmember)]
		public Guid entityid
		{
            get
            {
                return LookupPropertyValue(CrmStr.entityid);
            }
            set
            {
                AddLookupProperty(CrmStr.entityid,DefaultEntityName,value);
            }
        }


        public string entityName
        {
            get
            {
                if (ContainsKey(CrmStr.entityid))
                    return LookupPropertyName(CrmStr.entityid);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.listmember)]
        public string entitytype
        {
            get
            {
                return StringPropertyValue(CrmStr.entitytype);
            }
            set
            {
                AddStringProperty(CrmStr.entitytype,value);
            }
        }

    }
}
